package edu.regiscollege.cs312.scheduler;

/** CPU that Scheduler uses to process Job.
 * 
 */
public class CPU {
	/** Executes a Job till completion
	 * 
	 * @param job the job to execute
	 * @return the time it takes to execute the job till completion
	 */
	public long execute(Job job) {
		return job.getRemainingTime();
	}

	/** Execute a Job till specified time, or completion, whichever is shorter.
	 * 
	 * @param job the job the execute
	 * @param sec at most execute the job for sec
	 * @return the amount of time the CPU process this job, it can be shorter than sec if
	 *         the remaining time of the job is smaller than sec.
	 */
	public long executeForNSecond(Job job, long sec) {
		return Math.min(sec, job.getRemainingTime());
	}
}
